package com.mojo.config;

import com.mojo.filter.MyFilter;
//import com.mojo.listener.MyListener;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author <a href="mailto:sjj@jianzhimao.com">mojo</a>
 * copyright (C), 2013-2021, 广州九尾信息科技有限公司
 * @date 2021/9/22 18:16
 */
@Configuration
@EnableConfigurationProperties(Car.class)
public class MyConfig {
    //@Bean
    //public ServletListenerRegistrationBean<MyListener> servletContextListener() {
    //    return new ServletListenerRegistrationBean<>(new MyListener());
    //}

    @Bean
    public FilterRegistrationBean<MyFilter> filterRegistrationBean() {
        MyFilter myFilter = new MyFilter();
        FilterRegistrationBean<MyFilter> filterRegistrationBean = new FilterRegistrationBean<>(myFilter);
        filterRegistrationBean.addUrlPatterns("/hello");
        return filterRegistrationBean;
    }
    @Bean
    @Primary
    public Car getCar() {
        System.out.println("==========>primary bean");
        return new Car();
    }
}
